<template>
  <div>
    <basic-container>
      <div class="banner-text">
         <div class="lettertop">
           <el-row>
          <el-col :span="8">
             <div class=" letterSX1">
               <span>银行分行</span>
                <el-select v-model="name" class="el-input" @change="provinces()" placeholder="请选择">
                  <el-option
                    v-for="item in tableDictItemData"
                    :key="item.label"
                    :label="item.label"
                    :value="item.value+','+item.label">
                  </el-option>
                </el-select>
             </div>
          </el-col>
          <el-col :span="16"><div class="letterSX letterSX2">
               <span>区域</span>
                  <el-select v-model="communityProvince" class="el-selectxx" @change="province()" placeholder="请选择">
                  <el-option
                    v-for="item in ProvinceList"
                    :key="item.areaCode"
                    :label="item.areaName"
                    :value="item.areaCode">
                  </el-option>
                </el-select>
                <el-select v-model="communityCity" class="el-selectxx" @change="City()" placeholder="请选择">
                  <el-option
                    v-for="item in CityList"
                    :key="item.areaCode"
                    :label="item.areaName"
                    :value="item.areaCode">
                  </el-option>
                </el-select>
                <el-select v-model="communityCounty"   class="el-selectxx"  placeholder="请选择">
                  <el-option
                    v-for="item in CountyList"
                    :key="item.areaCode"
                    :label="item.areaName"
                    :value="item.areaCode">
                  </el-option>
                </el-select>
             </div></el-col>
        
        </el-row>
        <el-row>
           <el-col :span="8">
              <div class="letterSX letterSX1">
               <span>分公司名称</span>
                <el-input
                placeholder="请输入分公司名称"
                v-model="realEstateBranch">
                </el-input>
             </div>
          </el-col>
          <el-col :span="8">
            <div class="letterSX letterSX1">
               <span>小区名称</span>
                <el-input
                placeholder="请输入小区名称"
                v-model.trim="communityName">
                </el-input>
             </div></el-col>
          <el-col :span="8"><div class="letterSX letterSX1">
               <span>小区地址</span>
                <el-input
                placeholder="请输入详细地址"
                v-model="communityAddress">
                </el-input>
             </div></el-col>
         
        </el-row>
        <el-row>
          <el-col :span="8"><div class="letterSX letterSX1">
               <span>车位总数(个)</span>
                <el-input
                placeholder="请输入车位总数"
                v-model.trim="parkSpaceSum">
                </el-input>
             </div></el-col>
          <el-col :span="8"><div class="letterSX letterSX1">
               <span>授信额度(元)</span>
                <el-input
                placeholder="请输入授信额度"
                v-model.trim="creditLine">
                </el-input>
             </div></el-col>
          <el-col :span="8"></el-col>
        </el-row>
         </div>
        <div class="lettertop"><el-row>
          <el-col :span="8"><div class="letterSX"></div></el-col>
          <el-col :span="8"><div class="letterSX">
            
             <el-button
                size="medium"
                icon="el-icon-close"
                @click="letterorbtn()">取消
              </el-button>
            <el-button
                class="filter-item"
                type="primary"
                size="medium"
                icon="el-icon-check"
                @click="lettersuccbtn()">提交
              </el-button>
            </div></el-col>
          <el-col :span="8"><div class="letterSX"></div></el-col>
          </el-row></div>
         
      </div>
      
    </basic-container>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import {add,getAllProvinceList,getChildByareaCode} from '@/api/cpls/cpls'
   import { fetchItemList} from '@/api/admin/dict'
export default {
  name: 'projectregistration',
  data() {
    return {
     ProvinceList:[],
      CityList:[],
      CountyList:[],
      activeNames: ['1', '2', '3', '4'],
      DATA: [],
      text: '',
      actor: '',
      count: 0,
      isText: false,
      name:null,
      communityProvince:null,
      communityCity:null,
      communityCounty:null,
      bankBranchesCode:null,
      bankBranches:null,
      xqmc:null,
      communityAddress: "",
      communityName: "",
      parkSpaceSum:"",
      creditLine: "",
      realEstateBranch: "",
      tableDictItemData:[]
      
    }
  },
  computed: {
    ...mapGetters(['website'])
  },
  created(){
   
    this.getProvinceList()
  },
  methods: {
   handleClick(scope,status){
        
      console.log(scope.row)
   },
   lettersuccbtn(){
     if(this.bankBranches=='' || this.bankBranches==null){
       this.$message.error('请选择银行分行');
       return false
     }
     if(this.communityCounty=='' || this.communityCounty==null){
       this.$message.error('请选择区域');
       return false
     }
     
     if(this.realEstateBranch=='' || this.realEstateBranch==null){
       this.$message.error('请填写分公司名称');
       return false
     }
     if(this.communityName=='' || this.communityName==null){
       this.$message.error('请填写小区名称');
       return false
     }
      if(this.communityAddress=='' || this.communityAddress==null){
       this.$message.error('请填写小区地址');
       return false
     }
      if(this.parkSpaceSum=='' || this.parkSpaceSum==null){
       this.$message.error('请填写车位总数');
       return false
     }
      if(this.creditLine=='' || this.creditLine==null){
       this.$message.error('请填写授信额度');
       return false
     }
     add({"bankBranches": this.bankBranches,
        "bankBranchesCode":this.bankBranchesCode,
        "communityAddress": this.communityAddress,
        "communityCity": this.communityCity,
        "communityCounty": this.communityCounty,
        "communityName": this.communityName,
        "communityProvince": this.communityProvince,
        // "createTime": "2020-08-04T07:46:53.874Z",
        // "createUser": "string",
        "creditLine": this.creditLine,
        // "lastUpdTime": "2020-08-04T07:46:53.874Z",
        // "lastUpdUser": "string",
        // "loanProjectId": "string",
        "parkSpaceSum": this.parkSpaceSum,
        "realEstateBranch": this.realEstateBranch
      }).then(response => {
    console.log(response)
            if(response.data.code =='0'){
                this.$message.success('新增成功');
                this.$router.push({ path: '/project/projectregistration' })
            }
      
        })
  
       //this.$router.push({ path: '/project/projectregistration' })
   },
   letterorbtn(){
     this.$router.push({ path: '/project/projectregistration' })
   },
    getProvinceList(){
      getAllProvinceList({
        
      }).then(response => {
    
          this.ProvinceList=response.data.data
      
        })
         fetchItemList(Object.assign({
          current: 1,
          size: 20
        }, {dictId: 195})).then(response => {
          this.tableDictItemData = response.data.data.records
        })
   },
   provinces(){
      this.bankBranchesCode=this.name.split(',')[0]
     this.bankBranches=this.name.split(',')[1]
   },
   province(){
      getChildByareaCode({
             areaCode:this.communityProvince
            }).then(response => {
         
            this.CityList=response.data.data
        
          })
   },City(){
      getChildByareaCode({
             areaCode:this.communityCity
            }).then(response => {
         
            this.CountyList=response.data.data
        
          })
   },
  }
}
</script>

<style scoped="scoped" lang="scss">
  .wel-contailer {
    position: relative;
  }
  .avue-view,.basic-container,.el-card{
    height: 100%;
  }
  .banner-text {
    position: relative;
    padding: 0 20px;
    font-size: 20px;
    text-align: center;
    color: #333;
  }
  .lettertop{
    margin-bottom: 20px;
  }
  .letterbottom{
    text-align: center;
  }
  .el-button--small{
    font-size: 14px;
  }
  td,tr{
    div{
      text-align: center;
    }
  }
  .letteright{
      text-align: right;
  }
  .letterdowimg{
      span{
         width: 120px;
         border-radius: 10px;
         border:1px solid #ccc;
         display: inline-block;
         height: 90px;
      }
  }
  .maskMenu {
  position: fixed;
  width: 100%;
  height: 100%;
  z-index: 999;
  background: rgba(0, 0, 0, 1);
  opacity: 0.4;
  top: 64px;
  left: 0;
}
  .pull_menu{
          width: 700px;
    height: auto;
    background: #fff;
    position: fixed;
    z-index: 1000;
    left: 50%;
    top: 50%;
    margin-top: -200px;
    padding:  20px;
    border-radius: 10px;
    margin-left: -350px;
  }
  .lettersuccbtn{
        display: inline-block;
        background: deepskyblue;
        color: #fff;
        border-radius: 10px;
        padding: 5px 35px;
        margin: 10px;
        cursor: pointer;
            font-size: 16px;
      }
      .letterorbtn{
        display: inline-block;
        border: 1px solid #ccc;
        border-radius: 10px;
        padding: 5px 35px;
        margin: 10px;
        cursor: pointer;
            font-size: 16px;
      }
      // #letterSX{
      //     .el-input{
      //       width: 150px;
      //     }
      // }
  // .letterSX{
  //   span{
  //         display: inline-block;
  //        line-height: 43px; 
  //        width: 40%;
  //        text-align: right;
  //       padding: 0px 20px;
  //           font-size: 16px;
  //     }
  // }
  .letterSX1{
     span{
          display: inline-block;
         line-height: 43px; 
         width: 40%;
         text-align: right;
        padding: 0px 15px;
            font-size: 16px;
      }
      .el-selectxx{
        width: 20%;
      }
     .el-input{
       width: 60%;
     }
  }
  .letterSX2{
     span{
          display: inline-block;
         line-height: 43px; 
         width: 20%;
         text-align: right;
        padding: 0px 15px;
            font-size: 16px;
      }
      .el-selectxx{
        width: 26.6%;
      }
     .el-input{
       width: 80%;
     }
  }

 

  .typeing:after {
    animation: none;
  }

  @keyframes blink {
    to {
      opacity: 0;
    }
  }
</style>
